require.config({
    baseUrl: '/static/js/libs',
    paths: {
        app: "../app"
    }
});

require(['jquery', 'sammy',"sammy.mustache"], function($,Sammy,SammyMustache){
  app = Sammy('#main', function() {
    this.use('Mustache', 'ms');

    this.get('/games/:id', function(context) {
      context.load('/games/' + this.params.id, {json: true})
        .then(function(data) {
          context.partial('/static/templates/game.ms',data);
      });
    });

    this.get('/', function(context) {
      context.app.swap('');
      context.load('/games/', {json: true})
        .then(function(data) {
          games = data.games
          context.games = games
          context.partial('/static/templates/game_list.ms');
      });
    });

  });
  app.run();
});
